package com.example.manager.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.manager.entity.CourseTeaching;
import com.example.manager.service.CourseTeachingService;

@RestController
public class CourseTeachingController {
	
	@Autowired
	private CourseTeachingService service;
	
	@GetMapping("courseTeaching")
	public List<CourseTeaching> getAllCourseTeaching(){
		return service.findAllCourseTeaching();
	}
	
	@GetMapping("courseTeachingByTid/{tid}")
	public List<CourseTeaching> getByTeacher(@PathVariable String tid) {
		return service.getByTeacher(tid);
	}
	
	@GetMapping("courseTeachingById/{id}")
	public CourseTeaching getById(@PathVariable Integer id) {
		return service.getById(id);
	}
	
	@PostMapping("courseTeaching")
	public String addCourseTeaching(CourseTeaching courseTeaching) {
		return service.addCourseTeaching(courseTeaching);
	}
	
	@PutMapping("courseTeaching/{id}")
	public String editCourseTeaching(CourseTeaching courseTeaching, @PathVariable Integer id) {
		return service.editCourseTeaching(courseTeaching);
	}
	
	@DeleteMapping("courseTeaching/{id}")
	public String delCourseTeaching(@PathVariable Integer id) {
		return service.deleteCourseTeaching(id);
	}
	
}
